<template>
	<!-- 账号密码登录 -->
	<view class="login">			
		 <view style="width:100%;height: 100px;" @click="black()">
			 <image src="../../../static/public/img/fanhui.png" style="width:20px;height: 20px;margin-top: 15%;margin-left: 5%;"></image>
		 </view>
		 <view style="width:100%;height: 90px;">
		 			 <image src="../../../static/public/img/20221130200228.png" style="width:40%;margin-left: 30%;height: 75px;"></image>
		 </view>
		 
		 <view style="width:92%;margin-left: 4%;background: #090909;border-radius: 10px;">
			 <view style="width:100%;height: 50px;border-bottom: 1px solid #303336;">
				 <image src="../../../static/public/img/zh.png" style="width: 40px;height: 40px;float: left;margin-top: 1%;margin-left: 3%;"></image>
				 <input type="number" placeholder="请输入会员账号" v-model="username" style="color:white;font-size: 12px;float: left;height: 50px;line-height: 50px;margin-left: 3%;">
			 </view>
			 <view style="width:100%;height: 50px;border-bottom: 1px solid #303336;">
				 <image src="../../../static/public/img/mm.png" style="width: 40px;height: 40px;float: left;margin-top: 1%;margin-left: 3%;"></image>
				 <input type="password" placeholder="请输入登录密码" v-model="password" style="color:white;font-size: 12px;float: left;height: 50px;line-height: 50px;margin-left: 3%;">
			 </view>
			 <view style="width:100%;height: 50px;border-bottom: 1px solid #303336;">
				 <image src="../../../static/public/img/yzm.png" style="width: 40px;height: 40px;float: left;margin-top: 1%;margin-left: 3%;"></image>
				 <input type="text" placeholder="请输入验证码" style="color:white;font-size: 12px;float: left;height: 50px;line-height: 50px;margin-left: 3%;width:55%">
				 <image src="../../../static/public/img/yzm.png" style="width: 40px;height: 40px;float: left;margin-top: 1%;margin-left: 3%;"></image>
			 </view>
		 </view>
		 
		 <view style="width:92%;margin-left: 4%;background: #090909;color: #f7cf94;font-size: 12px;float: left;margin-top: 10%;height: 30px;line-height: 30px;">
		 	 <view style="float: left;margin-left: 4%;">忘记密码？</view>
			 <view style="float: left;margin-left: 50%;">
				 <checkbox-group @change="checkBoxmA" >
					 <checkbox value ='0' :checked="allCk" color="black" style="transform:scale(0.5)">
					  </checkbox>
				 </checkbox-group>
			 </view>
			  <view style="float: left;margin-left:0%;">记住密码</view>
			  <view style="width:100%;background: #090909;float: left;padding-bottom:10%;">
				  <button style="margin-top: 10%;color: #614b33;background-image: linear-gradient(180deg,#e6b87a,#d49a53 80%);width:90%;margin-left: 5%;" @click="login()">登录</button>
				  <button style="color: #ffab1c!important;background-image: linear-gradient(180deg,#625138,#463c2f);width:90%;margin-left: 5%;margin-top: 3%;">注册</button>
			  </view>
		 </view>
		 
		 <view style="width:100%;position: fixed;bottom: 30px;color: #f7cf94;text-align: center;font-size: 12px;">
			  <image src="../../../static/public/img/zxkf.png" style="width: 20px;height: 20px;float: left;left: 40%;"></image>
			 在线客服
		 </view> 
		 
		 
	</view>
</template> 

<script> 
	export default {
		data() {
			return {
				
			}
		},

		methods: {
			// 跳转 注册账号 页面
			gotoRegister() {
				uni.navigateTo({
					url: '/pages/components/login/register_true'
				})
			},
			black(){
				uni.navigateTo({
					url: '/pages/components/home/home'
				})
			},
			// 登录
			login() {
				var self = this
					this.isVerificationPass = true;
					
					if(!this.username || this.username.length<6 || this.username.length>12){
						return this.$api.msg('请输入正确的会员账号')
					}
					if(!this.password){
						return this.$api.msg('请输入登录密码')
					}
					uni.showLoading({
						title:'登录中...'
					})
					// 发起登录请求
					self.$api.request('/api/user/login',{
						username: this.username,
						password: this.password
					}).then(res=>{
						if(res.code != 200){
							uni.hideLoading()
							return this.$api.msg(res.message)
						}
						this.$api.msg('登录成功')
						if(res.code == 200){
							uni.setStorageSync('token',res.data.token)
							setTimeout(()=>{
								uni.switchTab({
									url: '/pages/components/home/home'
								});
							},1000)
						}
					})
			},
			cp() {
				this.$api.request('/api/login/cp').then((res)=>{
					console.log(res)
				})
			}
	
		},
		onReady() {
	
		},
		onLoad() {
			this.cp()
		}
	}
</script>

<style lang="scss" scoped>
	page{
		background: #121213;
	}
	// 账号密码登录
	.login {
	  uni-checkbox .uni-checkbox-input {
			width: 22px;
			height: 22px;
		}
	}
</style>
